#include <bits/stdc++.h>
using namespace std;

struct FastIO {
	inline FastIO& operator >> (short& x) {
		x = 0;
		char f = 0, ch = getchar();
		while (ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
		while (ch <= '9' && ch >= '0') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
		return x = (f ? -x : x), *this;
	}
	inline FastIO& operator >> (int& x) {
		x = 0;
		char f = 0, ch = getchar();
		while (ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
		while (ch <= '9' && ch >= '0') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
		return x = (f ? -x : x), *this;
	}
	inline FastIO& operator >> (long long& x) {
		x = 0;
		char f = 0, ch = getchar();
		while (ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
		while (ch <= '9' && ch >= '0') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
		return x = (f ? -x : x), *this;
	}
	inline FastIO& operator >> (double& x) {
		x = 0;
		char f = 0, ch = getchar();
		double d = 0.1;
		while (ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
		while (ch <= '9' && ch >= '0') x = x * 10 + (ch ^ 48), ch = getchar();
		if (ch == '.') {
			ch = getchar();
			while (ch <= '9' && ch >= '0') x += d * (ch ^ 48), d *= 0.1, ch = getchar();
		}
		return x = (f ? -x : x), *this;
	}
} rin;

#define ll long long
#define uint unsigned int
#define reg register
#define ld long double
#define uint unsigned int
#define ull unsigned long long
#define qint const int&
#define qll const ll&
#define quint cosnt uint&
#define qull const ull&
#define endl "\n"

inline void qmod(int& x, const int& mod) {
	x = x >= mod? x - mod : x;
}

const int N = 5e5 + 10, M = 1e6 + 10, inf = 0x3f3f3f;
//int st;
int q;
multiset<int> st1, st2, stl[M], str[M];
multiset<int> trl[M << 1], trr[M << 1];
int mn[M << 1], ls[M << 1], rs[M << 1], mnr[M << 1], mxl[M << 1], cnt, rt;

void build(int &u, int l, int r) {
	u = ++cnt;
	mn[u] = mnr[u] = inf;
	mxl[u] = -inf;
	if (l == r) return;
	int mid = (l + r) >> 1;
	build(ls[u], l, mid);
	build(rs[u], mid + 1, r);
}

void addl(int u, int l, int r, int qx, int x) {
	if (l == r) {
		trl[u].insert(x);
		mxl[u] = *trl[u].rbegin();
		return;
	}
	int mid = (l + r) >> 1;
	if (qx <= mid) addl(ls[u], l, mid, qx, x);
	else addl(rs[u], mid + 1, r, qx, x);
	mn[u] = min(mn[ls[u]], mn[rs[u]]);
	mxl[u] = max(mxl[ls[u]], mxl[rs[u]]);
	mn[u] = min(mn[u], mnr[rs[u]] - mxl[ls[u]] + 1);
}
void addr(int u, int l, int r, int qx, int x) {
	if (l == r) {
		trr[u].insert(x);
		mnr[u] = *trr[u].begin();
		return;
	}
	int mid = (l + r) >> 1;
	if (qx <= mid) addr(ls[u], l, mid, qx, x);
	else addr(rs[u], mid + 1, r, qx, x);
	mn[u] = min(mn[ls[u]], mn[rs[u]]);
	mnr[u] = min(mnr[ls[u]], mnr[rs[u]]);
	mn[u] = min(mn[u], mnr[rs[u]] - mxl[ls[u]] + 1);
}
void dell(int u, int l, int r, int qx, int x) {
	if (l == r) {
		trl[u].erase(trl[u].find(x));
		mxl[u] = trl[u].empty()? -inf : *trl[u].begin();
		return;
	}
	int mid = (l + r) >> 1;
	if (qx <= mid) dell(ls[u], l, mid, qx, x);
	else dell(rs[u], mid + 1, r, qx, x);
	mn[u] = min(mn[ls[u]], mn[rs[u]]);
	mxl[u] = max(mxl[ls[u]], mxl[rs[u]]);
	mn[u] = min(mn[u], mnr[rs[u]] - mxl[ls[u]] + 1);
}
void delr(int u, int l, int r, int qx, int x) {
	if (l == r) {
		trr[u].erase(trr[u].find(x));
		mnr[u] = trr[u].empty()? inf : *trr[u].rbegin();
		return;
	}
	int mid = (l + r) >> 1;
	if (qx <= mid) delr(ls[u], l, mid, qx, x);
	else delr(rs[u], mid + 1, r, qx, x);
	mn[u] = min(mn[ls[u]], mn[rs[u]]);
	mnr[u] = min(mnr[ls[u]], mnr[rs[u]]);
	mn[u] = min(mn[u], mnr[rs[u]] - mxl[ls[u]] + 1);
}

signed main() {
	freopen("stone.in", "r", stdin);
	freopen("stone.out", "w", stdout);
	rin >> q;
	build(rt, 1, 1e6);
	char op;
	for (int i = 1, l, r; i <= q; ++i) {
		cin >> op, rin >> l >> r, --r;
		if (op == 'A') {
			st1.insert(r), st2.insert(l);
			stl[r].insert(l), str[l].insert(r);
			addl(1, 1, 1e6, r, l), addr(1, 1, 1e6, l, r);
		} else {
			st1.erase(st1.find(r)), st2.erase(st2.find(l));
			stl[r].erase(stl[r].find(l)), str[l].erase(str[l].find(r));
			dell(1, 1, 1e6, r, l), delr(1, 1, 1e6, l, r);
		}
		int L = *st2.rbegin(), R = *st1.begin();
		if (L <= R) cout << (*str[L].begin()) - (*stl[R].rbegin()) + 1 << endl;
		else cout << mn[rt] << endl;
	}
//	int ed;
//	cerr << (&ed - &st) / 1024 / 1024 << endl;
	return 0;
}
